﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Music
{
    public partial class GUI : Form
    {
        public Album Gal = new Album();

        public GUI()
        {
            InitializeComponent();
        }

        public GUI(Album G)
        {
            InitializeComponent();
            Gal = G;
        }

        public void GUI_get_new_al(Album G)
        {
            Gal = G;
        }

        private void GUI_Load(object sender, EventArgs e)
        {
            for (int i = 0; i < Gal.album.Count; i++)
            {
                String s = Gal.album[i].GetType().ToString();
                switch (s)
                {
                    case "Music.PopTrack":
                        listBox1.Items.Add(((PopTrack)Gal.album[i]).GetMusician() + " - " + ((PopTrack)Gal.album[i]).GetName() + " [Pop]");
                        break;
                    case "Music.ClassicTrack":
                        listBox1.Items.Add(((ClassicTrack)Gal.album[i]).GetMusician() + " - " + ((ClassicTrack)Gal.album[i]).GetName() + " [Classic]");
                        break;
                    case "Music.RockTrack":
                        listBox1.Items.Add(((RockTrack)Gal.album[i]).GetMusician() + " - " + ((RockTrack)Gal.album[i]).GetName() + " [Rock]");
                        break;
                    case "Music.TrackWithVocal":
                        listBox1.Items.Add(((TrackWithVocal)Gal.album[i]).GetMusician() + " - " + ((TrackWithVocal)Gal.album[i]).GetName() + " [Vocal]");
                        break;
                    case "Music.TrackWithoutVocal":
                        listBox1.Items.Add(((TrackWithoutVocal)Gal.album[i]).GetMusician() + " - " + ((TrackWithoutVocal)Gal.album[i]).GetName() + " [WithoutVocal]");
                        break;
                    case "Music.AbstractTrack":
                        listBox1.Items.Add(((AbstractTrack)Gal.album[i]).GetMusician() + " - " + ((AbstractTrack)Gal.album[i]).GetName() + " [AbstractTrack]");
                        break;
                }
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            Create_form CF = new Create_form();
            
            CF.ShowDialog();

            Album cF = CF.CFAl;
            for (int i = 0; i < cF.album.Count; i++)
            {
                String s = cF.album[i].GetType().ToString();
                switch (s)
                {
                    case "Music.PopTrack":
                        Gal.Add((PopTrack)cF.album[i]);
                        break;
                    case "Music.ClassicTrack":
                        Gal.Add((ClassicTrack)cF.album[i]);
                        break;
                    case "Music.RockTrack":
                        Gal.Add((RockTrack)cF.album[i]);
                        break;
                    case "Music.TrackWithVocal":
                        Gal.Add((TrackWithVocal)cF.album[i]);
                        break;
                    case "Music.TrackWithoutVocal":
                        Gal.Add((TrackWithoutVocal)cF.album[i]);
                        break;
                    case "Music.AbstractTrack":
                        Gal.Add((AbstractTrack)cF.album[i]);
                        break;
                }
                
            }
            
            listBox1.Items.Clear();

            for (int i = 0; i < Gal.album.Count; i++)
            {
                String s = Gal.album[i].GetType().ToString();
                switch (s)
                {
                    case "Music.PopTrack":
                        listBox1.Items.Add(((PopTrack)Gal.album[i]).GetMusician() + " - " + ((PopTrack)Gal.album[i]).GetName() + " [Pop]");
                        break;
                    case "Music.ClassicTrack":
                        listBox1.Items.Add(((ClassicTrack)Gal.album[i]).GetMusician() + " - " + ((ClassicTrack)Gal.album[i]).GetName() + " [Classic]");
                        break;
                    case "Music.RockTrack":
                        listBox1.Items.Add(((RockTrack)Gal.album[i]).GetMusician() + " - " + ((RockTrack)Gal.album[i]).GetName() + " [Rock]");
                        break;
                    case "Music.TrackWithVocal":
                        listBox1.Items.Add(((TrackWithVocal)Gal.album[i]).GetMusician() + " - " + ((TrackWithVocal)Gal.album[i]).GetName() + " [Vocal]");
                        break;
                    case "Music.TrackWithoutVocal":
                        listBox1.Items.Add(((TrackWithoutVocal)Gal.album[i]).GetMusician() + " - " + ((TrackWithoutVocal)Gal.album[i]).GetName() + " [WithoutVocal]");
                        break;
                    case "Music.AbstractTrack":
                        listBox1.Items.Add(((AbstractTrack)Gal.album[i]).GetMusician() + " - " + ((AbstractTrack)Gal.album[i]).GetName() + " [AbstractTrack]");
                        break;
                }
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            int temp = listBox1.SelectedIndex;
            listBox1.Items.RemoveAt(temp);
            Gal.album.RemoveAt(temp);
        }

        private void button3_Click(object sender, EventArgs e)
        {
            int temp = listBox1.SelectedIndex;

            String s = Gal.album[temp].GetType().ToString();
            switch (s)
            {
                case "Music.PopTrack":
                    MessageBox.Show("Название трека: " + ((PopTrack)Gal.album[temp]).GetName() + " [" + ((PopTrack)Gal.album[temp]).GetYear() + "] \nИсполнитель: " + ((PopTrack)Gal.album[temp]).GetMusician() + "\nВокалист: " + ((PopTrack)Gal.album[temp]).GetVocalist() + "\nЧисло партий синтезатора: " + ((PopTrack)Gal.album[temp]).GetSP());
                    break;
                case "Music.ClassicTrack":
                    MessageBox.Show("Название трека: " + ((ClassicTrack)Gal.album[temp]).GetName() + " [" + ((ClassicTrack)Gal.album[temp]).GetYear() + "] \nИсполнитель: " + ((ClassicTrack)Gal.album[temp]).GetMusician() + "\nКомпозитор: " + ((ClassicTrack)Gal.album[temp]).GetComposer() + "\nВедущий инструмент: " + ((ClassicTrack)Gal.album[temp]).GetMIn());
                    break;
                case "Music.RockTrack":
                    MessageBox.Show("Название трека: " + ((RockTrack)Gal.album[temp]).GetName() + " [" + ((RockTrack)Gal.album[temp]).GetYear() + "] \nИсполнитель: " + ((RockTrack)Gal.album[temp]).GetMusician() + "\nВокалист: " + ((RockTrack)Gal.album[temp]).GetVocalist() + "\nЧисло гитарных партий: " + ((RockTrack)Gal.album[temp]).GetGP() + "\nЧисло ударных партий: " + ((RockTrack)Gal.album[temp]).GetDP());
                    break;
                case "Music.TrackWithVocal":
                    MessageBox.Show("Название трека: " + ((TrackWithVocal)Gal.album[temp]).GetName() + " [" + ((TrackWithVocal)Gal.album[temp]).GetYear() + "] \nИсполнитель: " + ((TrackWithVocal)Gal.album[temp]).GetMusician() + "\nВокалист: " + ((TrackWithVocal)Gal.album[temp]).GetVocalist());
                    break;
                case "Music.TrackWithoutVocal":
                    MessageBox.Show("Название трека: " + ((TrackWithoutVocal)Gal.album[temp]).GetName() + " [" + ((TrackWithoutVocal)Gal.album[temp]).GetYear() + "] \nИсполнитель: " + ((TrackWithoutVocal)Gal.album[temp]).GetMusician() + "\nКомпозитор: " + ((TrackWithoutVocal)Gal.album[temp]).GetComposer());
                    break;
                case "Music.AbstractTrack":
                    MessageBox.Show("Название трека: " + ((AbstractTrack)Gal.album[temp]).GetName() + " [" + ((AbstractTrack)Gal.album[temp]).GetYear() + "] \nИсполнитель: " + ((AbstractTrack)Gal.album[temp]).GetMusician());
                    break;
            }
        }
    }
}
